/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package src.java.com.inse6260.atms.model;

import com.inse6260.atms.model.BankDatabase;

/**
 *
 * @author seif
 */
public class transfer
{

    private int accountNumber1;
    private int accountNumber2;
    private float transferAmount;

    private BankDatabase bankDatabase;

    /**
     * Instantiates transfer object with accountNumber and amount
     * @param accountNumber BankClient account number
     * @param transferAmount transfer amount
     */
    public transfer(BankDatabase bankDatabase, int accountNumber1, int accountNumber2, float transferAmount)
    {
        // initialize fields
        this.accountNumber1 = accountNumber1;
        this.accountNumber2 = accountNumber2;
        this.transferAmount = transferAmount;
        this.bankDatabase = bankDatabase;
    }

    /**
     * Executes transaction
     */
    public void execute()
    {
        bankDatabase.credit(accountNumber2, transferAmount);
        bankDatabase.debit(accountNumber1, transferAmount);
    }


}
